TCA (Dependencies) で Generics を使う

How to handle Generics in Environment Clients? · pointfreeco/swift-composable-architecture · Discussion #1069

public struct StorageClient {
  var _save: (String, Data) -> Void
  var _load: (String) -> Data

  public func save<T: Encodable>(key: String, value: T) throws {
    self._save(key, try JSONEncoder().encode(value))
  }
  public func load<T: Decodable>(key: String, as type: T.Type) throws -> T {
    try JSONDecoder().decode(T.self, from: self._load(key))
  }
}

swift-composable-architecture swift-dependencies Swift